import state from "./state";

const mutations = {
	setUserKey(state, {
		uid,
		token
	}) {
		state.uid = uid
		state.token = token
		// state.loggedIn = true
		// 将用户信息持久化到本地存储
		uni.setStorageSync('uid', {
			uid
		})
		
		uni.setStorageSync('token', {
			token
		})
	},
	setUserInfo(state,userInfo){
		 state.userInfo = userInfo
		 uni.setStorageSync('userInfo', {
			userInfo
		})
	},
	clearUserInfo(state) {
		// 清除本地存储中的用户信息
		state.uid = null
		state.token = null
		uni.removeStorageSync('uid')
		uni.removeStorageSync('token')
		state.userInfo = null
		uni.removeStorageSync('userInfo')
	}
}
export default mutations